<template>
	<view>
		<view class="teamitem" v-for="(item,index) in datas" :key="index">
			<view class="user marginAuto flex">
				<view class="useravatar">
					<image v-if="!item.invite_user_avatar" src="@/static/logo.png" mode=""></image>
					<image v-if="item.invite_user_avatar" :src="apifun.URLimg+item.invite_user_avatar" mode=""></image>
				</view>
				<view class="userr">
					<view class="userrname flex">
						<view>{{ item.invite_user_name }}</view>
						<view class="headmsgmtx flex">
							<view class="headmsgmtxl mainBg">
								<image :src="apifun.serveimg+'cardicon.png'" mode=""></image>
							</view>
							<view class="headmsgmtxr">{{ item.invite_user_school }}</view>
						</view>
					</view>
					<view class="userjx ellipsis01">团队名称：{{ item.invite_user_team }}</view>
					<view class="userrtime">{{ item.create_time }}</view>
				</view>
				<view class="userbtn mainBg baiColor" @click="$refs.guarantee.open();acitem = item;acindex=index">是否接受</view>
			</view>
		</view>
		<uv-popup ref="guarantee" bgColor="none" round="20">
			<view class="closetest">
				<image class="closetestbg" :src="apifun.serveimg+'closetestbg.png'" mode=""></image>
				<view class="closetesttitle" style="font-weight: 600;padding-top:60rpx;"></view>
				<view class="closetestdoc" style="margin-top:30rpx;">该教练邀请你进入团队</view>
				<view class="closetestbtn flex">
					<view class="closetestbtne mainColor" style="background: #ffffff;" @click="turnfun()">拒绝</view>
					<view class="closetestbtne mainBg baiColor" @click="acceptfun()">接受</view>
				</view>
			</view>
		</uv-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				datas:[],
				acitem:{},
				acindex:0
			};
		},
		onLoad() {
			this.getauthlistfun()
		},
		methods: {
			acceptfun(){  // 接受
				let sendData = {
					id:this.acitem.id
				};
				this.apifun.unirequest('/coach/order/accept','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.$refs.guarantee.close();
						this.datas.splice(this.acindex,1)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			turnfun(){  // 拒绝
				let sendData = {
					id:this.acitem.id
				};
				this.apifun.unirequest('/coach/order/refuse','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.$refs.guarantee.close();
						this.datas.splice(this.acindex,1)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			getauthlistfun(){
				this.apifun.unirequest('/coach/order/getAuthList','post',{},(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.datas = datas;
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
		},
	};
</script>

<style scoped lang="scss">
	@import '../../public/alert.scss';
	.teamitem{
		.user{
			position: relative;
			width: 650rpx;
			padding:20rpx;
			margin-bottom: 20rpx;
			background: #fff;
			.useravatar{
				width: 136rpx;
				height: 136rpx;
				margin-top: 10rpx;
				image{
					width: 136rpx;
					height: 136rpx;
					border-radius: 50%;
				}
			}
			.userr{
				width: 80%;
				margin-left: 20rpx;
				.userrname{
					line-height: 60rpx;
					font-size:30rpx;
					color: #333333;
					.headmsgmtx{
						height: 44rpx;
						border: 1px solid #0E71EB;
						margin-left: 20rpx;
						margin-top:6rpx;
						border-radius: 100rpx;
						background: #fff;
						.headmsgmtxl{
							padding:0 10rpx;
							border-radius: 100rpx;
							image{
								margin-top: 5rpx;
								width: 34rpx;
								height: 34rpx;
							}
						}
						.headmsgmtxr{
							padding: 0 20rpx;
							font-size:24rpx;
							line-height: 44rpx;
							color: #0E71EB;
						}
					}
				}
				.userjx{
					line-height: 50rpx;
					font-size:26rpx;
					color: #333333;
				}
				.userrtime{
					font-size: 24rpx;
					color: #666666;
					line-height:36rpx;
				}
				.userrbzj{
					font-size:24rpx;
					color: #0E71EB;
					line-height:40rpx;
				}
			}
			.userbtn{
				position: absolute;
				right: 20rpx;
				bottom: 20rpx;
				width: 160rpx;
				height: 60rpx;
				line-height: 60rpx;
				text-align: center;
				font-size:28rpx;
				border-radius:10rpx;
			}
		}
	}
</style>